import Vue from 'vue'
import VueRouter from 'vue-router'
// 不是按需导入 所有的路由资源都会参与打包
// 打包优化的时候 改写成动态import导入写法 按需加载
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import My from '@/views/My'
import Home from '@/views/Home'
import Detail from '@/views/Detail'
import EditUser from '@/views/My/EditMy.vue'
import Search from '@/views/Search'
import SearchResult from '@/views/Search/Result.vue'

Vue.use(VueRouter)

// 路由表
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // 二级路由的path为空 当前的二级路由将作为默认的二级渲染
        component: Home
      },
      {
        path: 'my',
        component: My
      },
      {
        path: 'search',
        component: Search
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/detail',
    component: Detail
  },
  {
    path: '/editUser',
    component: EditUser
  },
  {
    path: '/searchResult',
    component: SearchResult
  }
]

const router = new VueRouter({
  routes
})

export default router
